package com.kelp.codetoolkit.enums

/**
 * @author: liuyuebai
 * @date: 2024/10/18 09:59
 * @description:
 */
enum class ServerPackageEnum(val suffix:String,val packageName:String) {

    SERVICE("Service","service"),
    SERVICE_IMPL("ServiceImpl","service/impl"),
    MAPPER_JAVA("Mapper","dao"),
    PROVIDER("Provider","provider"),
    PROVIDER_IMPL("ProviderImpl","provider"),
    CONTROLLER("Controller","controller"),
    ;
    companion object {
        fun getServerPackageEnumBySuffix(suffix:String): ServerPackageEnum {
            return values().find { it.suffix == suffix }!!
        }

        fun getServerPackageEnumByClassName(className: String): ServerPackageEnum? {
            val values = values()
            for (value in values) {
                if (className.endsWith(value.suffix)) {
                    return value
                }
            }
            return null
        }

        fun isService(className:String):Boolean{
            return className.endsWith(SERVICE.suffix)
        }

        fun isServiceImpl(className:String):Boolean{
            return className.endsWith(SERVICE_IMPL.suffix)
        }
        fun isJavaMapper(className:String):Boolean{
            return className.endsWith(MAPPER_JAVA.suffix)
        }
        fun isProvider(className:String):Boolean{
            return className.endsWith(PROVIDER.suffix)
        }
        fun isProviderImpl(className:String):Boolean{
            return className.endsWith(PROVIDER_IMPL.suffix)
        }
        fun isController(className:String):Boolean{
            return className.endsWith(CONTROLLER.suffix)
        }

    }
}